import 'package:library_base/entities/generated/json/base/json_convert_content.dart';
import 'package:library_base/entities/car_entity.dart';
import 'package:library_base/entities/purchase_order_entity.dart';
import 'package:library_base/entities/suppliers_shops_list_entity.dart';

PurchaseOrderEntity $PurchaseOrderEntityFromJson(Map<String, dynamic> json) {
  final PurchaseOrderEntity loginBeanEntity = PurchaseOrderEntity();

  loginBeanEntity.details = jsonConvert.convertList(json['details']);

  final String? purchaseId = jsonConvert.convert<String>(json['purchaseId']);
  if (purchaseId != null) {
    loginBeanEntity.purchaseId = purchaseId;
  }

  final String? purchaseOrderNumber = jsonConvert.convert<String>(json['purchaseOrderNumber']);
  if (purchaseOrderNumber != null) {
    loginBeanEntity.purchaseOrderNumber = purchaseOrderNumber;
  }

  final double? purchaseAmount = jsonConvert.convert<double>(json['purchaseAmount']);
  if (purchaseAmount != null) {
    loginBeanEntity.purchaseAmount = purchaseAmount;
  }

  final double? purchaseCount = jsonConvert.convert<double>(json['purchaseCount']);
  if (purchaseCount != null) {
    loginBeanEntity.purchaseCount = purchaseCount;
  }

  final String? payStatus = jsonConvert.convert<String>(json['payStatus']);
  if (payStatus != null) {
    loginBeanEntity.payStatus = payStatus;
  }

  final String? purchaseTime = jsonConvert.convert<String>(json['purchaseTime']);
  if (purchaseTime != null) {
    loginBeanEntity.purchaseTime = purchaseTime;
  }

  final String? supplierName = jsonConvert.convert<String>(json['supplierName']);
  if (supplierName != null) {
    loginBeanEntity.supplierName = supplierName;
  }

  final String? remark = jsonConvert.convert<String>(json['remark']);
  loginBeanEntity.remark = remark??"";

  final double? totalCost = jsonConvert.convert<double>(json['totalCost']);
  if (totalCost != null) {
    loginBeanEntity.totalCost = totalCost;
  }

  if(json['shop'] == null){
    loginBeanEntity.shop = null;
  }else{
    loginBeanEntity.shop = SuppliersShopsListEntity.fromJson(json['shop']);
  }

  return loginBeanEntity;
}

Map<String, dynamic> $PurchaseOrderEntityToJson(PurchaseOrderEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};

  data['purchaseId'] = entity.purchaseId;
  data['purchaseOrderNumber'] = entity.purchaseOrderNumber;
  data['purchaseAmount'] = entity.purchaseAmount;
  data['purchaseCount'] = entity.purchaseCount;
  data['payStatus'] = entity.payStatus;
  data['purchaseTime'] = entity.purchaseTime;
  data['totalCost'] = entity.totalCost;
  data['details'] = entity.details;
  data['remark'] = entity.remark;
  data['supplierName'] = entity.supplierName;
  data['shop'] = entity.shop;

  return data;
}
